#ifndef __bitmap_h
#define __bitmap_h
#include <fstream>
#include <istream>
#include <ostream>
#include <iostream>

#include "Palette.h"
#include "SmartArray.h"

class Bitmap: public SmartObject
{
	private:
		struct
		{
			char mMagic[2];// = { 'B', 'M' }
			unsigned int mFileSize;
			unsigned short mReserve[2]; // = { 0,0 }.
			unsigned int mRelativePixels;
		} FileHeader;
		struct
		{
			unsigned int mHeaderSize; //=40.
			unsigned int mWidth,mHeight;
			unsigned short mNumPlanes; // = 1.
			unsigned short mBPP;//Bits Per Pixel.
			unsigned int mCompressionMethod;//We only support non-compressed( 0 ).
			unsigned int mImageDataSize;
			unsigned int mPixelsPerMeter[2]; // = { 0, 0 }.
			unsigned int mColorDetails[2];//= {0,0}.
		} Header;
		char* pixelData;
		SmartArray<Palette> Palettes;
	protected:
	public:
		void ExportToFile( std::ostream& blob );
		void LoadFromFile( std::istream& blob);
		Bitmap( const char* );
		Bitmap();
		~Bitmap();
		Palette& GetPalette( int);
		unsigned int NumPals();
};
#endif